//---------------------------------------------------------------------------

#ifndef CEditUpDownH
#define CEditUpDownH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include "CEdit.h"
#include <ComCtrls.hpp>
#include "CtrlStd.h"
//---------------------------------------------------------------------------
class PACKAGE_CTRLSTD CEditUpDown : public TCustomPanel
{
private:
  typedef void __fastcall (__closure* TChangeEvent)( TObject* pedSender);
  TChangeEvent             m_pfnOnChange;
  
  CEdit *m_Edit;
  TUpDown *m_UpDown;
  TLabel *LLibelle;

  AnsiString FLibelle;
  TFont *FLibelleFont;
  TColor ColorParent;         // Sauvegarde de la couleur avant passage en Disabled
  int FSizeEsp;
  
private:
  int __fastcall GetMinMax(int index) const;
  void __fastcall SetMinMax(int index,int MinMax);
  void __fastcall CEdit1IllegalChar(CCustomEdit *pedSender,WORD &cIllegalCharCode,bool &bAccept);
  void __fastcall CEdit1IllegalPaste(CCustomEdit *pedSender,AnsiString &strClipText,bool &bAccept);
  void __fastcall Edit1Exit(TObject *Sender);
  void __fastcall SetLibelle(const AnsiString libelle);
  TFont *__fastcall GetLibelleFont() const;
  void __fastcall SetLibelleFont(TFont *Fonte);
  bool __fastcall GetEnabled();
  void __fastcall SetEnabled(bool enabled);
  bool __fastcall GetReadOnly() const;
  void __fastcall SetReadOnly(bool Readonly);
  void __fastcall LibelleFontChange(TObject *Sender);
  void __fastcall PaintBkGrnd(TColor Color);
  void __fastcall SetSizeEsp(int iSizeEsp);
  bool __fastcall GetVisible() const;
  void __fastcall SetVisible(bool visible);
  void __fastcall m_EditChange(TObject *Sender);
  void __fastcall m_UpDownClick(TObject *Sender, TUDBtnType Button);
  bool __fastcall GetObligatoire( void);
  void __fastcall SetObligatoire( bool bObligatoire);
  bool __fastcall GetBleuSiHint( void);
  void __fastcall SetBleuSiHint( bool bBleuSiHint);
  TCorrectementRempliEvent __fastcall GetOnEstCorrectementRempli();
  void __fastcall SetOnEstCorrectementRempli (TCorrectementRempliEvent OnEstCorrectementRempli);
  bool __fastcall GetTabStop();
  void __fastcall SetTabStop(bool _bTabStop);
  void __fastcall ReplaceLibelle()
    {
      LLibelle->Left = Left - (FSizeEsp >= 0 ? LLibelle->Width + FSizeEsp : -FSizeEsp);
      LLibelle->Top = Top - (LLibelle->Height - Height) / 2;
    }
protected:
  __property Height = {stored = false};
  void __fastcall WndProc(TMessage &Message);
public:
  __fastcall CEditUpDown(TComponent* Owner);
  virtual __fastcall ~CEditUpDown();
__published:
  __property int Min = {read = GetMinMax,write = SetMinMax,index = 0};
  __property int Max = {read = GetMinMax,write = SetMinMax,index = 1};
  __property int Position = {read = GetMinMax,write = SetMinMax,index = 2};
  __property AnsiString Libelle = {read = FLibelle,write = SetLibelle};
  __property int SizeEspace = {read = FSizeEsp,write = SetSizeEsp};
  __property TFont *LibelleFont = {read = GetLibelleFont,write = SetLibelleFont};
  __property bool Enabled  = {read = GetEnabled,write = SetEnabled,default = true};
  __property bool ReadOnly = {read = GetReadOnly,write = SetReadOnly,default = false};
  __property bool Visible = {read = GetVisible,write = SetVisible,default = true};
  __property TabOrder;
  //__property TabStop;
  __property bool TabStop  = {read = GetTabStop,write = SetTabStop,default = true};
  __property TChangeEvent OnChange = { read = m_pfnOnChange, write = m_pfnOnChange};
  __property bool Obligatoire = { read = GetObligatoire, write = SetObligatoire, default = false };
  __property bool BleuSiHint = { read = GetBleuSiHint, write = SetBleuSiHint, default = false };  
  __property TCorrectementRempliEvent OnEstCorrectementRempli = { read = GetOnEstCorrectementRempli, write = SetOnEstCorrectementRempli};
};
//---------------------------------------------------------------------------
#endif
